Skip to content

fix(mcp): make local-endpoint budgets configurable - #1856

Open
NullSense wants to merge 1 commit into
repowise-dev:mainfrom
NullSense:fix/local-endpoint-timeout-overrides
Open

fix(mcp): make local-endpoint budgets configurable#1856
NullSense wants to merge 1 commit into
repowise-dev:mainfrom
NullSense:fix/local-endpoint-timeout-overrides

Conversation

@NullSense

Copy link
Copy Markdown

Summary

  • tool_answer/config.py: _SYNTHESIS_MAX_TOKENS (1024, hardcoded) now reads REPOWISE_SYNTHESIS_MAX_TOKENS. A reasoning model spends its whole budget on hidden thinking before emitting an answer token, so the call comes back empty at the old cap; measured against nanbeige, 1024 tokens returned nothing, 8192 produced a correct, cited answer.
  • _answer_pipeline.py / _helpers.py: _EMBED_TIMEOUT_S (8.0, hardcoded) now reads REPOWISE_EMBED_TIMEOUT_S via a new embed_timeout_s(), mirroring the sibling vector_search_timeout_s(). A cold-loading local embedding model blows the old 8s budget; get_answer still exits 0 with the semantic leg silently dropped, visible only at WARNING.
  • One PR because it's one root cause: constants tuned for a warm remote service, with no override, that degrade silently on a local one. Both follow the existing pattern for REPOWISE_EMBEDDING_TIMEOUT / REPOWISE_VECTOR_SEARCH_TIMEOUT_S: an unparseable or non-positive override warns and keeps the default.

Related Issues

None.

Test Plan

  • uv run pytest tests/unit/ -q — 14242 passed, 12 skipped, 2 xfailed. 2 failures, both pre-existing on unmodified main and unrelated to this change: a git-rebase test that depends on local git config, and a timezone-sensitive episode-dating test.
  • uv run ruff check .
  • uv run repowise risk main..HEAD:
    Change risk for main..HEAD: touches files that have broken before · 90th percentile of this repo's fix-bearing files
      fix(mcp): make local-endpoint budgets configurable
      +269 / -12 lines · 7 files · 3 dirs · 2 subsystems · entropy 2.19 · author exp 0  (fix)
    
    File                                                                       Lines   Prior fixes
    packages/server/src/repowise/server/mcp_server/tool_answer/config.py         36           11.7
    packages/server/src/repowise/server/mcp_server/_helpers.py                   36            6.4
    tests/unit/server/mcp/test_answer_synthesis_timeout.py                       47            5.8
    packages/server/src/repowise/server/mcp_server/_answer_pipeline.py           19            4.9
    packages/server/src/repowise/server/mcp_server/tool_answer/synthesis.py       6            2.8
    
    Diff shape: Typical · 57th percentile of recent commits by size and spread
      About as risky as a typical commit in this repo.
    
    This flags real history: these are exactly the answer-pipeline files this fix targets, and they carry a documented run of prior fixes (config.py alone shows a recency-weighted 11.7). That matches the PR's own premise — this is a bug-prone area — rather than indicating a new problem in this diff; the full-suite result above is the direct check on that.
    (impacted-tests / health --file need a completed repowise init against this clone; that indexing run did not finish in time and is omitted rather than faked.)

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • All existing tests still pass
  • I have updated documentation if needed

Written with AI assistance; measurements and tests were run and verified locally.

@Ayush7614 Ayush7614 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: pytest tests/unit/server/mcp/test_answer_synthesis_timeout.py tests/unit/server/mcp/test_embed_timeout.py -q 76 passed. Makes two hardcoded budgets configurable (REPOWISE_SYNTHESIS_MAX_TOKENS for reasoning models spending budget on hidden thinking, REPOWISE_EMBED_TIMEOUT_S via embed_timeout_s() mirroring vector_search_timeout_s()) with validate-and-warn fallback, correct 120s cap, and updated degraded message advertising the env var. Hotspot history (config.py 11.7 fixes) matches the bug-prone area being fixed — not a new risk. LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants